$(function () {
  $("#show_place .load_more").attr('disabled', '');
  var tmp = location.pathname.split('/');
  var username = tmp[tmp.length-2];
  var notes_e = $("#show_place #notes");
  var ret = append_notes(notes_e, 10, Infinity, "/notes/api/notes?username="+username);
  var notes_cnt = ret[0];
  var max_id = ret[1];
  $("#show_place #max_id").val(max_id);
  if (notes_cnt < 10) {
    $("#show_place .load_more").attr("disabled", "disabled");
  }
  
  $("#show_place .load_more").click(function () {
    var max_id = $("#show_place #max_id").val();
    var tmp = location.pathname.split('/');
    var username = tmp[tmp.length-2];
    var notes_e = $("#show_place #notes");
    var ret = append_notes(notes_e, 10, max_id, "/notes/api/notes?username="+username);
    var notes_cnt = ret[0];
    var max_id = ret[1];
    $("#show_place #max_id").val(max_id);
    if (notes_cnt < 10) {
      $("#show_place .load_more").attr("disabled", "disabled");
    }
    return false;
  });
  $("#profile a[href='#message']").click(function () {
      open_post_message_dialog(username);
  });
});


$(function(){
    $("#add_friend_cancel").click(function(){
        $.unblockUI(); 
    });
});

function add_friend() {
    $.blockUI({
        message: $("#make_friend"),
        css: {
            cursor: 'default'
        }
    });
}

function add_friend_backend() {
    var username = $('#make_friend_username').val();
    var fuid = $('#make_friend_fuid').val();
    $.ajax({
        url:'/accounts/api/friend',
        type:'get',
        data:'username='+username+'&fuid='+fuid,
        success: function(data, textStatus) {
            alert(data);
            $.unblockUI();
        },
        error: function(req, textStatus,errors) {
            //TODO: add process error
            alert(" add friends error ")
            $.unblockUI();
        },
    });
}


